package javaClassExercise.constructorTest;

/**
 * Created by lomo.
 * 构造器，继承 之间的一些关联
 */
public class Dog extends Animal{
    public Dog(){
        super(123);
        //或
        //super("Lomo");
    }

    public static void main(String[] args) throws Exception{
        Dog dog = (Dog)Class.forName("javaClassExercise.constructorTest.Dog").newInstance(); // 1
        System.out.println(dog.getAge()); //123
    }
}

class Animal {
    private String name;
    private int age;

//    public Animal() {
//        System.out.println("1");
//    }

    public Animal(String name) {
        this.name = name;
    }

    public Animal(int age) {
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public int getAge() {
        return age;
    }

}